﻿using System;
using System.Globalization;
using NUnit.Framework;
using Pantry.DataAccess;
using Pantry.Entity;

namespace Pantry.UnitTest
{
    [TestFixture]
    public class TestTeamDao
    {
        private const string ConnectionString = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
        private TeamDao teamDao;
        private Team team;

        [SetUp]
        public void Init()
        {
            teamDao= new TeamDao(ConnectionString);
            team = new Team
                       {
                           TeamId = 1,
                           TeamName = "Consider",
                           ShortDescription = "This team important",
                           FullDescription = "This team very important",
                           DepartmentId = 1,
                           ContactId = 1,
                           TypeOfBusinessId = 1,
                           AddressLine1 = "So 1 Pham Hung",
                           AddressLine2 = "So 2 Pham Hung",
                           AddressLine3 = "So 3 Pham Hung",
                           Postcode = "123",
                           Town = "Cau Giay",
                           County = "Ha Noi",
                           CountryId = 1,
                           Phone = "01689987456",
                           Fax = "0456987123",
                           Email = "abc@fsoft.com.vn",
                           WebAddress = "http://fsoft.com.vn",
                           IsActive = true,
                           Date = Convert.ToDateTime(@"9/9/9")
                       };
        }

        [Test]
        public void TestRetrieveTeam()
        {
            var actual = (Team)teamDao.RetrieveEntity(1);
            Assert.AreEqual(1,actual.TeamId);
        }

        [Test]
        public void TestInsertTeam()
        {
            var actual = teamDao.Insert(team);
            Assert.AreEqual(-2, actual);
        }

        [Test]
        public void TestUpdateTeam()
        {
            var actual = teamDao.Update(team);
            Assert.AreEqual(-2, actual);
        }

        [Test]
        public void TestVerifyPostcode()
        {
            var actual = teamDao.CheckUnique("County", "Postcode", "80");
            Assert.AreEqual(false, actual);
        }

        [Test]
        public void TestChangeInActiveTeam()
        {
            var actual = teamDao.ChangeIsActive("Team","TeamName","1","TeamId",1);
            Assert.AreEqual(1, actual);
        }
    }
}
